package com.etc.emsys.controller;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.MenuBar;
import javafx.stage.Stage;

public class BaseMenuController extends BaseContrller {
	@Override
	public void initialize(URL location, ResourceBundle resources) {
		if (this.pre == null) {
			if (this.back != null) {
				this.back.setDisable(true);
			}
		}
	}

	@FXML
	public Button back;
	// 传值用
	public static Object param;
	/**
	 * 需要container
	 */
	@FXML
	public MenuBar menubar;
	
	public void menuEmpDelete() {


	}

	public void menuEmpUpdate() {


	}
	public void goback() {
			Scene scene = menubar.getScene();
			Stage stage = (Stage) scene.getWindow();
			stage.setScene(pre);
			stage.setTitle("返回");
			BaseContrller.pre = null;
			this.back.setDisable(true);
	}
	public void menuEmpSearch() throws IOException {
		// 跳转scene 的方法
		this.transformmenu("../view/emp/main.fxml", "员工检索", null);
	}
	public void menuEmpAdd() throws IOException {

		// 跳转scene 的方法
		this.transformmenu("../view/emp/empAdd.fxml", "员工添加", null);
	}
	public void menuDeptSearch() {


	}
	public void menuDeptAdd() {


	}
	public void menuDeptDelete() {


	}
	public void menuDeptUpdate() {


	}
	
	public void transformmenu(String url, String title, Object data) {
		try {
			FXMLLoader loader = new FXMLLoader(getClass()
		            .getResource(url));
			BaseMenuController.param = data; 
			Parent parent = loader.load();
			Scene scene = menubar.getScene();
	        scene.setRoot(parent);
	        Stage stage = (Stage) scene.getWindow();
	        stage.setTitle(title);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	        
	}


}
